695 stories
·
0 followers

The case of the invalid instruction exception on an instruction that should never have executed

2 Shares

The image processing folks added specialized AVX2 versions of their code, but found that it was crashing with an illegal instruction exception. The code went something like this:

void SwizzleAVX2(uint32_t* source, uint32_t* destination, uint32_t count)
{
    ⟦ do stuff using AVX-only instructions ⟧
    ⟦ such as _mm256_cvtepu8_epi16 ⟧
}

void SwizzleSSE4(uint32_t* source, uint32_t* destination, uint32_t count)
{
    ⟦ do stuff using SSE4 instructions ⟧
    ⟦ such as _mm_cvtepu8_epi16 ⟧
}

bool hasAVX2; // initialized elsewhere

void Swizzle(uint32_t* source, uint32_t* destination, uint32_t count)
{
    if (hasAVX2) {
        SwizzleAVX2(source, destination, count);
    } else {
        SwizzleSSE4(source, destination, count);
    }
}

This looks good, doesn’t it? We check whether AVX2 instructions are available, and if so, we use the AVX2 version; otherwise we use the SSE4 version.

But in fact, this code crashes with an invalid instruction exception on systems that do not have AVX2. How can that be?

Compiler optimization.

According to the “as-if” rule, the compiler is permitted to perform any optimization that a program cannot legitimately detect, where “legitimately” means “within the rules of the language”.

What happened is that the compiler first inlined the SwizzleAVX2 and SwizzleSSE4 functions into the Swizzle function, and then it reordered the instructions so that some of the AVX2 instructions from SwizzleAVX2 were moved in front of the test of the hasAVX2 variable. For example, maybe SwizzleAVX2 started by setting some registers to zero. The compiler might have decided to do this because profiling revealed that hasAVX2 is usually true, so it wants to get the registers ready in anticipation of using them for the rest of the SwizzleAVX2 function.

Unfortunately, the compiler doesn’t realize that our test of hasAVX2 was specifically intended to prevent any AVX2 instructions from running. The concept of “instructions that might not be available” does not arise in the C or C++ language specifications, so there is nothing in the language itself that addresses the matter.

There are some directives you can use to tell the compiler that certain memory operations must occur in a specific order. For example, you can use interlocked operations with acquire or release semantics, or you can use std::atomic_thread_fence, or you can use explicit memory barriers.

However, none of them are of use here because the offending instruction isn’t a memory instruction, so memory ordering directives have no effect.

The (somewhat unsatisfying) solution was to mark the AVX version as noinline so that the compiler cannot reorder instructions out of it.

__declspec(noinline)
void SwizzleAVX2(uint32_t* source, uint32_t* destination, uint32_t count)
{
    ⟦ do stuff using AVX-only instructions ⟧
    ⟦ such as _mm256_cvtepu8_epi16 ⟧
}

The post The case of the invalid instruction exception on an instruction that should never have executed appeared first on The Old New Thing.

Read the whole story
Share this story
Delete

Happy 20th to Imogen Heap’s Speak for Yourself

1 Share

Imogen Heap is always up to exciting new things, but let's take a moment to celebrate 20 years ago. Her landmark Speak for Yourself turns 20, and it's getting. a proper part with a vinyl release (at last), a remaster, and even the chance to listen to "Hide and Seek" in Spatial Audio on Apple Music. Good timing, too: the TikTok generation has made "Headlock" a surprise second smash from this album. Now the full record gets a second life.

The post Happy 20th to Imogen Heap’s Speak for Yourself appeared first on CDM Create Digital Music.

Read the whole story
Share this story
Delete

How Android phones became an earthquake warning system

1 Share

If you're the owner of an Android phone and live in a seismically active region, there's a chance your phone has popped up an unusual warning. Not one that asks for permission to share personal information, or potential malware, but something far more serious: There's an earthquake nearby, and you have up to a minute or two to get to a safer location.

Starting in the US in 2020 and expanding internationally since, the system is called Android Earthquake Alert (AEA), and it's on by default in most Android phones. And today, Google has a paper in Science that describes how the system works, how the company has improved it, and what it has seen during the first few years of operation, including what caused a handful of false alarms.

Shaking things up

Smartphones come with accelerometers, small devices that enable them to sense changes in motion. This is how they manage to do tricks like figuring out how many steps you're walking. If your phone is sitting quietly on a table, however, the accelerometer shouldn't be registering much significant motion. But anything from you walking across the room to a truck going by outside can cause vibrations that your phone's accelerometer can pick up. As can the often less subtle vibrations of earthquakes.

Part of the system Google has devised is a method of telling the two apart. And part of it is using that determination to alert people with enough time to do something about the impending arrival of potentially destructive seismic waves.

If you happen to be right near the epicenter, your phone will be among the first to pick up the shaking of the earthquake, and there's no way for an alert to do you much good. However, your phone could potentially help others, as the vibrations that it senses move through the Earth's crust at speeds that are relatively slow compared to the sorts of low-latency signals that convey information on the Internet, some of which operate at the speed of light. That means the phones that are initially shaken can be used to trigger a system that will get off a warning that can potentially reach other phones seconds or even minutes ahead of destructive seismic waves.

Of course, the trick is that you only send out the warning if there's an actual earthquake, and not when a truck is passing by. Here, the sheer volume of Android phones sold plays a key role. As a first pass, AEA can simply ignore events that aren't picked up by a lot of phones in the same area. But we also know a lot about the patterns of shaking that earthquakes produce. Different waves travel at different speeds, cause different types of ground motion, and may be produced at different intensities as the earthquake progresses.

So, the people behind AEA also include a model of earthquakes and seismic wave propagation, and check whether the pattern seen in phones' accelerometers is consistent with that model. It only triggers an alert when there's widespread phone activity that matches the pattern expected for an earthquake.

Raising awareness

In practical terms, AEA is distributed as part of the core Android software, and is set to on by default, so it is active in most Android phones. It starts monitoring when the phone has been stationary for a little while, checking for acceleration data that's consistent with the P or S waves produced by earthquakes. If it gets a match, it forwards the information along with some rough location data (to preserve privacy) to Google servers. Software running on those servers then performs the positional analysis to see if the waves are widespread enough to have been triggered by an earthquake.

If so, it estimates the size and location, and uses that information to estimate the ground motion that will be experienced in different locations. Based on that, AEA sends out one of two alerts, either "be aware" or "take action." The "be aware" alert is similar to a standard Android notification, but it plays a distinctive sound and is sent to users further from the epicenter. In contrast, the "take action" warning that's sent to those nearby will display one of two messages in the appropriate language, either "Protect yourself" or "Drop, cover, and hold on." It ignores any do-not-disturb settings, takes over the entire screen, and also plays a distinct noise.

If, for some reason, the alert reaches the phone after the seismic waves would have, it simply lets the user know that an earthquake has occurred, and gives them the option of learning more about the event.

As of the end of March last year, the system has sent a total of 1,279 events, ranging in magnitude from 1.9 to 7.8, with the largest event occurring in Türkiye. Over that time, software updates have improved the service, with things like the error in magnitude estimates dropping considerably. Some of these things involved improvements in the earthquake modeling based on local conditions in different parts of the world, in terms of both rock structure and building construction. Others were considerably more practical, such as ensuring the alerts didn't include vibrating the phone, which would make them useless for gathering data that would refine location and magnitude estimates.

And the system is remarkably fast. A 2023 event that took place 40 kilometers offshore in the Philippines took about 12 seconds before phones on shore started picking up the initial seismic waves. Alerts started going out about six seconds later and gave those who would experience the worst shaking up to 15 seconds of warning. For the larger event in Türkiye, warnings could have been received well over a minute before shaking started.

Overall, over a third of the people who could have received alerts say they got one before the shaking started. Roughly a quarter report receiving it during the sharking, and another quarter immediately after the quake became perceptible.

Widespread service

Of those roughly 1,300 events that triggered alerts, only three were false positives. One of those was triggered by a different system sending an alert that vibrated a lot of phones, something that should be relatively easy to compensate for in software. The other two were both due to thunderstorms, where heavy thunder caused widespread vibrations centered on a specific location. This led the team to better model acoustic events, which should prevent something similar from happening in the future.

While a number of countries had already built systems that could send out alerts using data from seismographic networks, AEA has extended this service so that 98 countries now have coverage, with 2.5 billion people able to receive alerts. The system now sends out an average of about 60 alerts per month, with about 18 million people receiving one.

Not bad for a system that relies on sensors that people get essentially for free when they purchase a phone. Here's hoping it's one of Google's longer-lived services.

Science, 2025. DOI: 10.1126/science.ads4779  (About DOIs).

Read full article

Comments



Read the whole story
Share this story
Delete

Experts lay into Tesla safety in federal autopilot trial

1 Share

This week, a federal court in Miami started hearing a wrongful death case involving Tesla's crash-prone Autopilot driver assistance system. It's not the first time that Tesla Autopilot has been implicated in fatal traffic crashes, but it is the first time that a federal court has heard such a case.

Until now, the most high-profile court case involving Tesla Autopilot was probably the California trial over the death of Walter Huang, who was killed in 2018 when his Tesla Model X steered itself into a concrete highway divider. Huang's family took Tesla to court in April 2024 but quickly settled with the automaker under terms that have been kept secret.

And earlier this week, Tesla settled another Autopilot lawsuit concerning the death of Jeremy Banner in 2019. In that case, the Tesla's sensors failed to recognize a tractor-trailer crossing the highway and collided with it, shearing the top off the car and killing Banner.

So far, Tesla has been unable to settle with the plaintiffs in the federal case, which also concerns a fatal crash in 2019 in Florida. In this case, in April 2019, a Tesla being driven by George McGee sped through a stop sign in the Florida Keys and struck Naibel Benavides and Dillon Angulo, who were standing near their car and stargazing. Benavides was killed, and Angulo was left with a brain injury.

"I feel like we were experimented on, and this technology was out on the road before it was safe," Angulo told an NBC interviewer in 2023.

What did the experts say?

Missy Cummings, a former fighter pilot and expert on autonomous systems, pulled few punches. Cummings, who received torrents of abuse from Tesla fans after being appointed to a senior advisor position at the National Highway Traffic Safety Administration in 2021, told the court that "it is my professional opinion that Tesla's Autopilot is defective because Tesla knowingly allows the car to be operated in operational domains for which it is explicitly not designed for."

Tesla's cockpit monitoring of drivers to ensure they remain alert "is simply not sufficient as keeping the driver engaged," Cummings told the court. And Tesla has a long history of "promoting the abuse and misuse of Autopilot." Cummings' testimony detailed her work at NHTSA investigating other fatal Tesla crashes, like the 2016 death of Joshua Brown, and detailed some of the interactions she and her agency had had with the car company.

For example, she said Tesla "clearly recognized that mode confusion is an issue—this is where people, for example, think the car is in Autopilot and don't understand that the Autopilot has disengaged," she told the court.

Cummings also referred to the deposition of Tesla autopilot firmware engineer Ajshay Phatak. Phatak's deposition told the court that the company did not keep good track of Autopilot crashes prior to 2018, and Cummings pointed out that "it was clear they knew that they had a big problem with people ignoring the warnings. Ignoring the hands-on requests. And...as you know, prior to this accident. It was known to Tesla that they were having problems with people ignoring their warnings."

Tesla's abuse of statistics to make misleading claims about safety are nothing new: in 2017, Ars found out that Tesla's claims about Autopilot reducing crashes was not at all backed by data, which in fact showed the driver assist actually increased crash rates.

Mendel Singer, a statistician at Case Western University School of Medicine, was very unimpressed with Tesla's approach to crash data statistics in his testimony. Singer noted that he was "not aware of any published study, any reports that are done independently... where [Tesla] actually had raw data and could validate it to see does it tend to make sense" and that the car company was not comparing like with like.

"Non-Teslas crashes are counted based on police reports, regardless of safety system deployment," Singer said. Further, Tesla kept misleading claims about safety on its website for years, Singer pointed out. When asked whether he would have accepted a paper for peer review from Tesla regarding its reports, "that would have been a really quick and easy rejection," he said.

While it's possible that Tesla will still settle this case, we may also see the trial carried out to its conclusion.

"The plaintiffs in this instance have already received compensation from the driver of the Tesla in question, apparently in a decent amount. My understanding is that this makes them much less likely to take the kinds of offers Tesla has been making for settlements, and this is more about the justice," said Edward Niedermeyer, author and long-time Tesla-watcher.

"That said, the judge in the case has made some frustrating rulings around confidentiality on key issues, so it's possible that may be in Tesla's favor. They could also just up their settlement offer enough to be impossible to refuse," Niedermeyer said.

Read full article

Comments



Read the whole story
Share this story
Delete

Trump admin squanders nearly 800,000 vaccines meant for Africa: Report

1 Share

Nearly 800,000 doses of mpox vaccine pledged to African countries working to stamp out devastating outbreaks are headed for the waste bin because they weren't shipped in time, according to reporting by Politico.

The nearly 800,000 doses were part of a donation promised under the Biden administration, which was meant to deliver more than 1 million doses. Overall, the US, the European Union, and Japan pledged to collectively provide 5 million doses to nearly a dozen African countries. The US has only sent 91,000 doses so far, and only 220,000 currently still have enough shelf life to make it. The rest are expiring within six months, making them ineligible for shipping.

"For a vaccine to be shipped to a country, we need a minimum of six months before expiration to ensure that the vaccine can arrive in good condition and also allow the country to implement the vaccination," Yap Boum, an Africa CDC deputy incident manager, told Politico.

Politico linked the vaccines' lack of timely shipment to the Trump administration's brutal cuts to foreign aid programs as well as the annihilation of the US Agency for International Development (USAID), which administered those aid programs.

A study published last month in The Lancet, estimated that funding and support from the USAID saved the lives of nearly 92 million people in 133 countries between 2001 and 2021, including the lives of over 30 million children under the age of 5. The study projected that the Trump administration's cuts will cost over 14 million lives by 2030—including 4.5 million children under age 5—unless the cuts are reversed.

The loss of mpox vaccines may help contribute to those figures. Politico notes that African countries have reported nearly 160,000 suspected mpox cases since the beginning of an outbreak last year, with some 46,000 confirmed. Nearly 1,900 people are suspected to have died of the infection.

Countries in Africa have been battling mpox for years. The viral infection causes a disease less severe than its eradicated relative, smallpox, but is still marked by a painful rash and flu-like symptoms. The World Health Organization declared the spread of mpox a public health emergency of international concern (PHEIC) in July 2022 and then again in August 2024. Last month, the WHO determined that the mpox situation continues to meet the criteria of a PHEIC and many countries in Africa continue to have sustained transmission.

Read full article

Comments



Read the whole story
Share this story
Delete

Stablecoin bill heads to Trump’s desk without blocks on presidential grifting

1 Share

Donald Trump is expected to sign the GENIUS Act into law Friday, securing his first big win as a self-described "pro-crypto president." The act is the first major piece of cryptocurrency legislation passed in the US.

The House of Representatives voted to pass the GENIUS Act on Thursday, approving the same bill that the Senate passed last month. The law provides a federal framework for stablecoins, a form of cryptocurrency that's considered less volatile than other cryptocurrencies, as each token is backed by the US dollar or other supposedly low-risk assets.

The GENIUS Act is expected to spur more widespread adoption of cryptocurrencies, since stablecoins are often used to move funds between different tokens. It could become a gateway for many Americans who are otherwise shy about investing in cryptocurrencies, which is what the industry wants. Ahead of Thursday's vote, critics had warned that Republicans were rushing the pro-industry bill without ensuring adequate consumer protections, though, seemingly setting Americans up to embrace stablecoins as legitimate so-called "cash of the blockchain" without actually insuring their investments.

A big concern is that stablecoins will appear as safe investments, legitimized by the law, while supposedly private companies issuing stablecoins could peg their tokens to riskier assets that could tank reserves, cause bank runs, and potentially blindside and financially ruin Americans. Stablecoin scams could also target naïve stablecoin investors, luring them into making deposits that cannot be withdrawn.

Representative Maxine Waters (D-Calif.)—part of a group of Democrats who had strongly opposed the bill—further warned Thursday that the GENIUS Act prevents lawmakers from owning or promoting stablecoins, but not the president. Trump and his family have allegedly made more than a billion dollars through their crypto ventures, and Waters is concerned that the law will make it easier for Trump and other presidents to use the office to grift and possibly even obscure foreign bribes.

"By passing this bill, Congress will be telling the world that Congress is OK with corruption, OK with foreign companies buying influence," Waters said Thursday, CBS News reported.

Some lawmakers fear such corruption is already happening. Senators previously urged the Office of Government Ethics in a letter to investigate why "a crypto firm whose founder needs a pardon" (Binance's Changpeng Zhao, also known as "CZ") "and a foreign government spymaker coveting sensitive US technology" (United Arab Emirates-controlled MGX) "plan to pay the Trump and Witkoff families hundreds of millions of dollars."

The White House continues to insist that Trump has "no conflicts of interest" because "his assets are in a trust managed by his children," Reuters reported.

Ultimately, Waters and other Democrats failed to amend the bill to prevent presidents from benefiting from the stablecoin framework and promoting their own crypto projects.

Markets for various cryptocurrencies spiked Thursday, as the industry anticipates that more people will hold crypto wallets in a world where it's fast, cheap, and easy to move money on the blockchain with stablecoins, as compared to relying on traditional bank services. And any fees associated with stablecoin transfers will likely be paid with other forms of cryptocurrencies, with a token called ether predicted to benefit most since "most stablecoins are issued and transacted on the underlying blockchain Ethereum," Reuters reported.

Unsurprisingly, ether-linked stocks jumped Friday, with the token's value hitting a six-month high. Notably, Bitcoin recently hit a record high; it was valued at above $120,000 as the stablecoin bill moved closer to Trump's desk.

GENIUS Act plants “seeds for the next financial crisis”

As Trump prepares to sign the law, Consumer Reports' senior director monitoring digital marketplaces, Delicia Hand, told Ars that the group plans to work with other consumer advocates and the implementing regulator to try to close any gaps in the stablecoin legislation that would leave Americans vulnerable.

Some Democrats supported the GENIUS Act, arguing that some regulation is better than none as cryptocurrency activity increases globally and the technology has the potential to revolutionize the US financial system.

But Hand told Ars that "we've already seen what happens when there are no protections" for consumers, like during the FTX collapse.

She joins critics that the BBC reported are concerned that stablecoin investors could get stuck in convoluted bankruptcy processes as tech firms engage more and more in "bank-like activities" without the same oversight as banks.

The only real assurances for stablecoin investors are requirements that all firms must publish monthly reserves backing their tokens, as well as annual statements required from the biggest companies issuing tokens. Those will likely include e-commerce and digital payments giants like Amazon, PayPal, and Shopify, as well as major social media companies.

Meanwhile, Trump seemingly wants to lure more elderly people into investing in crypto, reportedly "working on a presidential order that could allow retirement accounts to be invested in private assets, such as crypto, gold, and private equity," the BBC reported.

Waters, a top Democrat on the House Financial Services Committee, is predicting the worst. She has warned that the law gives "Trump the pen to write the rules that would put more money in his family’s pocket" while causing "consumer harm" and planting "the seeds for the next financial crisis."

Analyst: End of Trump’s crypto wins

The House of Representatives passed two other crypto bills this week, but those bills now go to the Senate, where they may not have enough support to pass.

The CLARITY Act—which creates a regulatory framework for digital assets and cryptocurrencies to allow for more innovation and competition—is "absolutely the most important thing" the crypto industry has been pushing since spending more than $119 million backing pro-crypto congressional candidates last year, a Coinbase policy official, Kara Calvert, told The New York Times.

Republicans and industry see the CLARITY Act as critical because it strips the Securities and Exchange Commission of power to police cryptocurrencies and digital assets and gives that power instead to the Commodity Futures Trading Commission, which is viewed as friendlier to industry. If it passed, the CLARITY Act would not just make it harder for the SEC to raise lawsuits, but it would also box out any future SEC officials under less crypto-friendly presidents from "bringing any cases for past misconduct," Amanda Fischer, a top SEC official under the Biden administration, told the NYT.

"It would retroactively bless all the conduct of the crypto industry," Fischer suggested.

But Senators aren't happy with the CLARITY Act and expect to draft their own version of the bill, striving to lay out a crypto market structure that isn't "reviled by consumer protection groups," the NYT reported.

And the other bill that the House sent to the Senate Thursday—which would ban the US from creating a central bank digital currency (CBDC) that some conservatives believe would allow for government financial surveillance—faces an uphill battle, in part due to Republicans seemingly downgrading it as a priority.

The anti-CBDC bill will likely be added to a "must-pass" annual defense policy bill facing a vote later this year, the NYT reported. But Marjorie Taylor Greene (R.-Ga.) "mocked" that plan, claiming she did not expect it to be "honored."

Terry Haines, founder of a Washington-based analysis firm Pangaea Policy, has forecasted that both the CLARITY Act and the anti-CBDC bills will likely die in the Senate, the BBC reported.

"This is the end of crypto's wins for quite a while—and the only one," Haines suggested. "When the easy part, stablecoin, takes [approximately] 4 to 5 years and barely survives industry scandals, it's not much to crow about."

Read full article

Comments



Read the whole story
Share this story
Delete
Next Page of Stories